﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using PSE.Deployment.TeamFoundation.Entity;

namespace PSE.Deployment.TeamFoundation.Logic
{
    public class PackageIterationBranch
    {
        #region [ Events ]
        public event EventHandler<PSE.Deployment.TeamFoundation.Entity.TraceEventArgs> TraceEvent;
        #endregion [ Events ]

        #region Singleton
        private static PackageIterationBranch instance;
        protected PackageIterationBranch()
        {
            Communication.PackageIterationBranch.Instance.TraceEvent += (sender, e) => TraceEvent(sender, e);
        }
        public static PackageIterationBranch Instance
        {
            get
            {
                if (instance == null)
                {
                    Mutex mutex = new Mutex();
                    mutex.WaitOne();

                    if (instance == null)
                        instance = new PackageIterationBranch();

                    mutex.Close();
                }
                return instance;
            }
        }
        #endregion Singleton

        public List<Entity.PackageIterationBranch> GetBranches(string sourceUri)
        {
            return Communication.PackageIterationBranch.Instance.GetBranches(sourceUri);
        }
    }
}
